package org.exia.minisig.services;

import java.util.ArrayList;

import org.exia.minisig.model.dao.PlaceDAO;
import org.exia.minisig.model.object.Place;

public class PlaceManager {
	//CONSTRUCTOR
	public PlaceManager() {
		initializeVar();
	}
	public void initializeVar(){
		
	}
	//METHODE
	public ArrayList<Place> getAll(){
		PlaceDAO placeDAO = new PlaceDAO();
		ArrayList<Place> listPlace = new ArrayList<>();
		for (Object newObject : placeDAO.getList()) {
			listPlace.add((Place)newObject);
		}
		return listPlace;
	}
	public void addPlace(Place _place){
		  PlaceDAO place = new PlaceDAO(_place);
		  //1 - Ajout a la table news
		  place.add();
		  place.setID();
		  //2- Ajout des image
		  place.linkImages();
	}
	public void removePlace(Place _place){
		PlaceDAO place = new PlaceDAO(_place);
		place.deleteImg();
		place.delete();
	}
	public void updateNews(Place _place){
		 PlaceDAO place = new PlaceDAO(_place);
		 //1. Supression des URL + IMG
		 place.deleteImg();
		 //2. Update
		 place.update();
		 //3.relier Image
		 place.linkImages();
	}
}
